package com.wu.family.model;
import java.util.HashMap;
 
import android.os.Parcel;
import android.os.Parcelable;
 
public class ParcelMap implements Parcelable {
    private HashMap<String, String> map;
 
    public ParcelMap() {
        map = new HashMap<String, String>(); 
    }
 
    public ParcelMap(Parcel in) {
        map = new HashMap<String, String>();
        readFromParcel(in);
    }
 
    public static final Parcelable.Creator<ParcelMap> CREATOR = new Parcelable.Creator<ParcelMap>() {
        public ParcelMap createFromParcel(Parcel in) {
            return new ParcelMap(in);
        }
 
        public ParcelMap[] newArray(int size) {
            return new ParcelMap[size];
        }
    };
 
    @Override
    public int describeContents() {
        return 0;
    }
 
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(map.size());
        for (String s: map.keySet()) {
            dest.writeString(s);
            dest.writeString(map.get(s));
        }
    }
 
    public void readFromParcel(Parcel in) {
        int count = in.readInt();
        for (int i = 0; i < count; i++) {
            map.put(in.readString(), in.readString());
        }
    }
 
    public String get(String key) {
        return map.get(key);
    }
 
    public void put(String key, String value) {
        map.put(key, value);
    }
    
    public void remove(String key) {
        map.remove(key);
    }

	/**
	 * @return the map
	 */
	public HashMap<String, String> getMap() {
		return map;
	}

	/**
	 * @param map the map to set
	 */
	public void setMap(HashMap<String, String> map) {
		this.map = map;
	}
}
